package controller;

import model.GameModel;
import controller.actions.BinAction;
import controller.actions.EntityAction;
import controller.actions.EntityClickedAction;
import controller.states.InGameState;

/**
 * Main Controller Context
 * 
 *
 */
public class GameController implements IState {
	
	private GameModel model;
	private IView view;
	private IState state;
	
	public GameController(GameModel model, IView view) {
		//this.setState(new InitialGameState(this));
		this.setState(new InGameState(this));
		this.model = model;
		this.view = view;
	}

	public void setState(IState state) {
		this.state = state;
	}
	
	public GameModel getModel() {
		return model;
	}

	@Override
	public void handleAction(IPlayerAction playerAction) {
		this.state.handleAction(playerAction);
	}

	@Override
	public void handleEntityClickedAction(EntityClickedAction action) {
		state.handleEntityClickedAction(action);
	}

	@Override
	public void handleEntityReleasedAction(EntityAction action) {
		state.handleEntityReleasedAction(action);
	}

	@Override
	public void handleEntityDraggedAction(EntityAction action) {
		state.handleEntityDraggedAction(action);		
	}

	public IView getView() {
		return view;
	}

	@Override
	public void handleBinClicked(BinAction action) {
		state.handleBinClicked(action);		
	}

	@Override
	public void handleBinDraggedAction(BinAction action) {
		state.handleBinDraggedAction(action);
	}

	@Override
	public void handleLevelLoadAction(String levelName) {
		state.handleLevelLoadAction(levelName);	
	}

}
